<?php

namespace App\Admin\Actions\Auction;

use App\Library\Logic\OperateLogLogic;
use App\Models\AuctionModel;
use Encore\Admin\Actions\Response;
use Encore\Admin\Actions\RowAction;
use Encore\Admin\Facades\Admin;

class AuctionStatusDownAction extends RowAction
{
    public $name = '下架';

    public function handle(AuctionModel $model): Response
    {
        $model->status = 0;
        $model->save();
        OperateLogLogic::add(Admin::user()->user_id, 'admin.auction.down', ['status' => 0]);
        return $this->response()->success('操作成功')->refresh();
    }

    public function dialog(): void
    {
        $this->confirm('是否确定下架?');
    }
}
